home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mntdoc01.zoo / mintdoc / cat3 / setbuf.3 < prev    next >
Encoding:
Text File  |  1993-03-03  |  2.8 KB  |  133 lines

  1.  
  2.  
  3.  
  4. SETBUF(3)           MINTLIB LIBRARY FUNCTIONS           SETBUF(3)
  5.  
  6.  
  7. N✓NA✓AM✓ME✓E
  8.        setbuf, setlinebuf, setvbuf - assign buffering to a stream
  9.  
  10. S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
  11.        #include <stdio.h>
  12.        #include <unistd.h> // Only needed for setlinebuf
  13.  
  14.        void setbuf(FILE *stream, char *buf);
  15.  
  16.        void setlinebuf(FILE *stream);
  17.  
  18.        int setvbuf(FILE *stream, char *buf, int type, size_t size);
  19.  
  20. D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
  21.        setbuf may be used after a  stream  has  been  opened  but
  22.        before  it is read or written. It causes the array pointed
  23.        to by buf to be used instead of an automatically allocated
  24.        buffer.   If  buf is the NULL pointer input/output will be
  25.        completely unbuffered.
  26.  
  27.        A constant BUFSIZ, defined in <stdio.h>, tells how big  an
  28.        array is needed:
  29.          char buf[BUFSIZ];
  30.  
  31.        setlinebuf  may be used after a stream has been opened and
  32.        after it is read or written. It changes the  buffering  on
  33.        stream from block/unbuffered to line buffered.
  34.  
  35.        setvbuf  may  be  used  after a stream has been opened but
  36.        before it is read or written. The  type  parameter  deter-
  37.        mines  how  stream will be buffered. Legal values for type
  38.        (defined in <stdio.h>) are:
  39.  
  40.          _IOFBF: causes input/output to be fully buffered.
  41.          _IOLBF: causes output to be line buffered; the buffer
  42.                  will be flushed when a newline is written,
  43.                  the buffer is full, or input is requested.
  44.          _IONBF: causes input/output to be fully unbuffered.
  45.  
  46.        If buf is not the NULL pointer, the  array  it  points  to
  47.        will  be  used  for buffering, instead of an automatically
  48.        allocated buffer. size specifies the size of the buffer to
  49.        be  used. The constant BUFSIZ in <stdio.h> is suggested as
  50.        a good buffer size. If input/output is unbuffered, buf and
  51.        size are ignored.
  52.  
  53.        By  default, output to a terminal is line buffered and all
  54.        other input/output is fully buffered.
  55.  
  56. S✓SE✓EE✓E A✓AL✓LS✓SO✓O
  57.        f✓fo✓op✓pe✓en✓n(✓(3✓3)✓),✓, g✓ge✓et✓tc✓c(✓(3✓3)✓),✓, p✓pu✓ut✓tc✓c(✓(3✓3)✓)
  58.  
  59. R✓RE✓ET✓TU✓UR✓RN✓N V✓VA✓AL✓LU✓UE✓ES✓S
  60.        setvbuf returns a non-zero value if an illegal  value  for
  61.  
  62.  
  63.  
  64. MiNT docs 0.1              3 March 1993                         1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SETBUF(3)           MINTLIB LIBRARY FUNCTIONS           SETBUF(3)
  71.  
  72.  
  73.        type  or size is provided; otherwise, it will return zero.
  74.  
  75. N✓NO✓OT✓TE✓ES✓S
  76.        A common source of error is allocating buffer space as  an
  77.        "automatic"  variable in a code block, and then failing to
  78.        close the stream in the same block.
  79.  
  80.        setlinebuf is available on BSD UN*X, and not on System V.
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. MiNT docs 0.1              3 March 1993                         2
  131.  
  132.  
  133.